package cn.wit.luohui.day11;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Map;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class StudentsScores extends Application {

	@Override
	public void start(Stage primaryStage) throws Exception {
//		String path="E:\\camp2018\\camp2018\\camp2018\\day10\\scores.csv";
		String path="E:\\camp2018\\camp2018\\camp2018\\day10\\scores.csv";
		System.out.println(new File(path).exists());

		BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(path),"gbk"));
		String line=null;
		int count=0;
		VBox box=new VBox();
		Map<String,Number> scores=new HashMap<>();
		Map<String,Number> scores1=new HashMap<>();
		String[] s=new String [4];
		while((line=br.readLine())!=null) {
			count++;
			if(count>1) {
			s=line.split(",");
			if(s[1].equals("线性代数")) {
			scores.put(s[2], Integer.valueOf(s[0]));
			
			}else {
				
			scores1.put(s[2], Integer.valueOf(s[0]));
			
			}
			}
			
		}
		box.getChildren().add(ChartUtils.createLineChart("线性代数",scores));
		box.getChildren().add(ChartUtils.createLineChart("高等数学（1）",scores1));
		Scene scene=new Scene(box);
	    primaryStage.setScene(scene);
		primaryStage.show();
		
	}
public static void main(String[] args) {
	launch(args);	
		
	}
	

}
